<template>

    <el-row type="flex" justify="space-between" style="align-items:auto;height:100%">
      <el-row type="flex"
        style="text-align: left;align-items:center"
      >
        <i
          class="el-icon-s-fold"
          style="font-size: 30px;line-height:1.3"
          @click="collapse">{{title}}</i
        >
      </el-row>

      <el-row type="flex" style="text-align: right;align-items:center">
        <el-avatar
          img :src="img"
          style="margin-right: 30px"
        ></el-avatar>

        <el-dropdown
          trigger="click"
          style="font-size: 20px;"
        >
          <span class="el-dropdown-link">
            {{username}}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="exit">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-row>
    </el-row>

</template>

<script>
import img from "../assets/touxiang.jpg";
export default {
  props:['title','username'],
  data(){
    return{
        img: img,
        title1:this.title,
        isCollapse:false
    }
  },
  methods:{
    collapse(){
      if(this.isCollapse)
        this.isCollapse=false
      else
        this.isCollapse=true
      this.$emit('postcollapse',this.isCollapse)
    },
    exit(){
      window.sessionStorage.removeItem("userInfo");
      this.$router.push({
        path:"/"
      })
    }
  },
  created(){
    // 发送axios请求，获取真数据
  },
  mounted(){
    // 通过ref获取组件实例，操作dom元素
  }
  
};
</script>

<style scoped>


</style>


